<template>
  <div id="dig">

    <el-card class="box-card">
      <div slot="header" class="clearfix">
        <span>邮箱</span>
      </div>
      <div>
        <el-row>
          <el-col :span="15">
            <div class="">
              <!-- <div>公司收益</div> -->
              <div class="grid-content "><div>
                <el-input v-model="params.gs" style="width: 300px;" placeholder="请输入邮箱地址" />
                <!-- <input type="file" multiple="multiple">  -->
                <!--multiple多选-->
                <!-- <input type="file" style="width:300px;" placeholder="请输入增加量"/> -->

              </div> </div>
            </div>
          </el-col>
          <!-- <el-col :span="5">

              <div class="grid-content ">运维收益: <div><el-input v-model="params.gs" style="width: 100px;" placeholder=""></el-input> %</div> </div>
            </el-col> -->

          <el-col :span="9">
            <div class="grid-content" style="margin-left: 100px;"><el-button type="primary" size="mini" @click="okseve(input)">保存</el-button></div>
          </el-col>

        </el-row>
        <!-- <el-divider></el-divider> -->
      </div>

    </el-card>
  </div>
</template>
<script>
// import { getInviteImgApi, setInviteImgApi } from '@/api/jackbo/platform.js'
import { getInviteImgApi, setInviteImgApi } from '../../api/placfg'
export default {
  name: 'Dig',
  data() {
    return {
      fileList: [

      ],
      params: {
        yw: '',
        gs: ''
      },
      action: '/defi/upload/1',
      listdata: [
        { title: '请输入需要增加的数量', value: '', n1: '', n2: '' }

      ]

    }
  },
  mounted() {
    this.getlist()
  },
  methods: {

    IsURL(value) {
      var strRegex = /^[a-zA-Z0-9_.-]+@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)*\.[a-zA-Z0-9]{2,6}$/
      var re = new RegExp(strRegex)

      if (!re.test(value)) {
        return false
      } else {
        return true
      }
    },

    handleChange(file, fileList) {
      // this.list
      console.log(file, fileList)
      this.fileList = fileList.slice(-1)
      console.log(file.response)
      if (file.response) {
        this.url = file.response.data
      }
    },
    async getlist() {
      const res = await getInviteImgApi()
      if (res.code == 0) {
        this.params.gs = res.data[3].confValue
        console.log(res.code)
      }
    },
    okseve() {
      if (!this.IsURL(this.params.gs)) {
        this.$message.error('请输入正确邮箱地址')
        return
      }
      const params = {
        delFlag: 0, // 0 跳转 ，1 不跳转
        type: 4, // 1 首页图片 ，2 邀请图片 ，3 视频 ，4 平台配置 5 币资讯，6官网地址 7 反馈
        address: this.params.gs // 地址
      }

      setInviteImgApi({
        ...params
      }).then(res => {
        if (res && res.code == 0) {
          this.$message.success('保存成功')

          // 重新获取新的数据
          this.getlist()
        }
      })
    },
    async determine(obj) {
      const params = {}
      if (obj == 1) {
        params.type = 1
        params.usdtCnt = this.params.oneUsdtCnt
        params.bokCnt = this.params.oneBokCnt
      } else if (obj == 5) {
        params.type = 2
        params.usdtCnt = this.params.fiveUsdtCnt
        params.bokCnt = this.params.fiveBokCnt
      } else if (obj == 10) {
        params.type = 3
        params.usdtCnt = this.params.tenUsdtCnt
        params.bokCnt = this.params.tenBokCnt
      }
      const res = await setInviteImgApi(params)
      if (res.code == 0) {
        this.getlist()
      }
      console.log(obj)
      // this.$message('我是确定')
    }
  }
}
</script>
  <style lang="scss" >
    .box-card{
      width: 97%;
      margin: 0 auto;
      margin-top: 20px;
    }
    #dig{
      .listbox{
        /* border-bottom: 1px solid #dddddd56; */
        margin-top: 40px;
      }
    }
    .el-row {
      margin-bottom: 20px;
      &:last-child {
        margin-bottom: 0;
      }
    }
    .el-col {
      border-radius: 4px;
    }
    .bg-purple-dark {
      background: #99a9bf;
    }
    .bg-purple {
      background: #d3dce6;
    }
    .bg-purple-light {
      background: #e5e9f2;
    }
    .grid-content {
      /* border-radius: 4px;
      min-height: 36px; */
      display: flex;
      align-items: center;
      justify-content: space-between;
      margin-bottom: 10px;
    }
    .row-bg {
      padding: 10px 0;
      background-color: #f9fafc;
    }
  </style>

  </style>
